package com.zhuimeng.redis_rocketmq.listen;

import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

@Component
@RocketMQMessageListener(topic = "KILLMESSAGE",consumerGroup = "redisConsume")
public class RedisRockMQLisren implements RocketMQListener<String> {
    private final String orderCount = "ORDERCOUNT";
    @Autowired
    private RedisTemplate redisTemplate;
    @Override
    public void onMessage(String s) {
        redisTemplate.boundValueOps(orderCount).decrement();
        System.out.println("当前还剩："+redisTemplate.boundValueOps(orderCount).get());
    }
}
